//Stepper
import 'package:flutter/material.dart';

/**
 *步骤
 */
class StepperDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return StepperStateDemo();
  }
}

class StepperStateDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return StepperState();
  }
}

class StepperState extends State<StepperStateDemo> {
  int _currentStep = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('StepperDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(8.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Theme(
              data: Theme.of(context).copyWith(
                primaryColor: Colors.black,
              ),
              child: Stepper(
                  //按下序列号
                  onStepTapped: (currentStepIndex) {
                    setState(() {
                      _currentStep = currentStepIndex;
                    });
                  },
                  //继续按钮
                  onStepContinue: () {
                    setState(() {
                      _currentStep < 2 ? _currentStep += 1 : _currentStep = 0;
                    });
                  },
                  //取消按钮
                  onStepCancel: (){
                    setState(() {
                      _currentStep >0 ? _currentStep -= 1 : _currentStep = 0;
                    });
                  },
                  currentStep: _currentStep,
                  steps: [
                    Step(
                      title: Text('Login'),
                      subtitle: Text('副标题-Login first'),
                      //步骤具体内容
                      content: Text('步骤具体内容步骤具体内容步骤具体内容'),
                      //步骤的激活状态
                      isActive: _currentStep == 0,
                    ),
                    Step(
                      title: Text('Choose plan'),
                      subtitle: Text('副标题-Choose plan'),
                      //步骤具体内容
                      content: Text('步骤具体内容步骤具体内容步骤具体内容'),
                      //步骤的激活状态
                      isActive: _currentStep == 1,
                    ),
                    Step(
                      title: Text('Confirm payment'),
                      subtitle: Text('副标题-Confirm payment'),
                      //步骤具体内容
                      content: Text('步骤具体内容步骤具体内容步骤具体内容'),
                      //步骤的激活状态
                      isActive: _currentStep == 2,
                    ),
                  ]),
            ),
          ],
        ),
      ),
    );
  }
}
